package com.kapcb.common.exception;

import com.kapcb.common.enums.ResultCodeEnum;
import lombok.Getter;

/**
 * <a>Title: ConditionException </a>
 * <a>Author: kapcb <a>
 * <a>Description: ConditionException <a>
 *
 * @author Kpacb
 * @version 1.0
 * @date 2024/4/28 22:04
 * @since 1.0
 */
@Getter
public class ConditionException extends RuntimeException {

    private static final long serialVersionUID = 8157004071159828033L;

    /**
     * 错误码
     */
    private final Integer code;

    public ConditionException() {
        this(ResultCodeEnum.BUSINESS_ERROR.code(), ResultCodeEnum.BUSINESS_ERROR.message());
    }

    public ConditionException(String message) {
        this(ResultCodeEnum.BUSINESS_ERROR.code(), message);
    }

    public ConditionException(Integer code, String message) {
        super(message);
        this.code = code;
    }
//
//    public ConditionException(Result result) {
//        this(result.code(), result.message());
//    }

    public ConditionException(ResultCodeEnum resultCodeEnum) {
        this(resultCodeEnum.code(), resultCodeEnum.message());
    }

//    protected ConditionException(Throwable throwable) {
//        this(ResultCodeEnum.BUSINESS_ERROR.code(), throwable);
//    }

//    protected ConditionException(Integer code, Throwable cause) {
//        super(cause);
//        this.code = code;
//    }
//
//    protected ConditionException(Integer code, String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
//        super(message, cause, enableSuppression, writableStackTrace);
//        this.code = code;
//    }
}
